package com.gzdh.dishrecognition.ui.fragment.sysset;

import static com.gzdh.dishrecognition.util.BitmapUtils.createColor;
import static com.gzdh.dishrecognition.util.BitmapUtils.drawableToBitmap;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.StateListDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.dhkj.web.idf.IdfRequestUtils;
import com.dhkj.web.idf.model.QueryWraper;
import com.dhkj.web.idf.model.RecognizeSet;
import com.dhkj.web.utils.MyObserverNo;
import com.dingmouren.colorpicker.ColorPickerDialog;
import com.dingmouren.colorpicker.OnColorPickerListener;
import com.gzdh.dishrecognition.R;
import com.gzdh.dishrecognition.ui.view.OptionItemView;

import java.util.Objects;

/**
 * 菜品识别设置
 */
public class IdentifyServerSetFragment extends Fragment {
    private Context mContext;


    public IdentifyServerSetFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mContext = inflater.getContext();
        View view = getViews();
        init();
        return view;
    }


    private RecognizeSet recognizeSet;

    private void init() {
        IdfRequestUtils.query(mContext, new MyObserverNo<QueryWraper>(mContext, false) {
            @Override
            public void onSuccess(QueryWraper result) {
                recognizeSet = result.getResult();
//                initShow();
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {

            }
        });
    }

    private void initShow() {
        if (recognizeSet.getIron_pan_mode() == 1) {
            panModeView.setRightText("开启");
        } else {
            panModeView.setRightText("关闭");
        }
        if (recognizeSet.getAmount_mode() == 1) {
            amountModeView.setRightText("开启");
        } else {
            amountModeView.setRightText("关闭");
        }
        if (recognizeSet.getNumber_mode() == 1) {
            numberModeView.setRightText("开启");
        } else {
            numberModeView.setRightText("关闭");
        }
        if (recognizeSet.getAuto_split_mode() == 1) {
            autoSplitModeView.setRightText("开启");
        } else {
            autoSplitModeView.setRightText("关闭");
        }
        if (recognizeSet.getBorder_show() == 1) {
            borderShowView.setRightText("开启");
        } else {
            borderShowView.setRightText("关闭");
        }
        if (recognizeSet.getName_show() == 1) {
            nameShowView.setRightText("开启");
        } else {
            nameShowView.setRightText("关闭");
        }
        if (recognizeSet.getPrice_show() == 1) {
            priceShowView.setRightText("开启");
        } else {
            priceShowView.setRightText("关闭");
        }
        String border_color = recognizeSet.getBorder_color();
        borderColorView.setRightImage(createColor(border_color));
        String font_color = recognizeSet.getFont_color();
        fontColorView.setRightImage(createColor(font_color));
        matchNumberView.setRightText(recognizeSet.getMatch_number() + "");
        templateNumberView.setRightText(recognizeSet.getTemplate_number() + "");
        saveDaysView.setRightText(recognizeSet.getImage_save_days() + "");
        templateThresholdView.setRightText(recognizeSet.getTemplate_threshold() + "");
        borderSizeView.setRightText(recognizeSet.getBorder_size() + "");
        fontSizeView.setRightText(recognizeSet.getFont_size() + "");





        borderColorView.setOnClickListener(v -> new ColorPickerDialog(mContext,
                Color.parseColor(border_color),false,new OnColorPickerListener() {
            @Override
            public void onColorCancel(ColorPickerDialog dialog) {

            }

            @Override
            public void onColorChange(ColorPickerDialog dialog, int color) {
            }

            @Override
            public void onColorConfirm(ColorPickerDialog dialog, int color) {
//                dish_i_d_f_border_color.setBackgroundColor(color);
//                if (recognizeSet != null) {
//                    String hexString = getHexString(color);
//                    recognizeSet.setBorder_color(hexString.replace("#ff","#"));
//                }
            }
        }).show());

        fontColorView.setOnClickListener(v -> new ColorPickerDialog(mContext,
                Color.parseColor(font_color),false,new OnColorPickerListener() {
            @Override
            public void onColorCancel(ColorPickerDialog dialog) {

            }

            @Override
            public void onColorChange(ColorPickerDialog dialog, int color) {
            }

            @Override
            public void onColorConfirm(ColorPickerDialog dialog, int color) {
//                dish_i_d_f_border_color.setBackgroundColor(color);
//                if (recognizeSet != null) {
//                    String hexString = getHexString(color);
//                    recognizeSet.setBorder_color(hexString.replace("#ff","#"));
//                }
            }
        }).show());
    }


    private View getViews() {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        LinearLayout mainLayout = new LinearLayout(mContext);
        mainLayout.setLayoutParams(layoutParams);
        mainLayout.setBackgroundColor(Color.WHITE);
        mainLayout.setOrientation(LinearLayout.VERTICAL);
        mainLayout.addView(getBody());        //主题内容
        return mainLayout;
    }


    private StateListDrawable getSelector() {
        StateListDrawable selector = new StateListDrawable();

        selector.addState(new int[]{android.R.attr.state_pressed}, ContextCompat.getDrawable(mContext, R.color.gray8));
        selector.addState(new int[]{android.R.attr.state_selected}, ContextCompat.getDrawable(mContext, R.color.white));
        selector.addState(new int[]{}, ContextCompat.getDrawable(mContext, R.color.white));

        return selector;
    }

    //铁盘模式
    OptionItemView panModeView;
    //识别大小份
    OptionItemView amountModeView;
    //检测数量
    OptionItemView numberModeView;
    //底片自动划分
    OptionItemView autoSplitModeView;
    //显示边框
    OptionItemView borderShowView;
    //显示菜品名称
    OptionItemView nameShowView;
    //显示菜品价格
    OptionItemView priceShowView;
    //边框颜色
    OptionItemView borderColorView;
    //字体颜色
    OptionItemView fontColorView;
    //识别个数
    OptionItemView matchNumberView;
    //最大底片
    OptionItemView templateNumberView;

    //保存周期
    OptionItemView saveDaysView;
    //未录入阈值
    OptionItemView templateThresholdView;
    //边框粗细
    OptionItemView borderSizeView;
    //字体大小
    OptionItemView fontSizeView;

    private View getBody() {
        ScrollView scrollView = new ScrollView(mContext);
        scrollView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));


        LinearLayout mainLinear = new LinearLayout(mContext);
        mainLinear.setOrientation(LinearLayout.VERTICAL);
        scrollView.addView(mainLinear);

        OptionItemView regView = new OptionItemView(mContext);
        LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 55);
        regView.setLayoutParams(linearParams);
        regView.setPadding(20, 20, 20, 20);
        regView.setBackground(getSelector());
        regView.setLeftImageMarginLeft(20);
        regView.setLeftImageMarginRight(18);
        regView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        regView.setLeftText("识别模式");
        regView.setLeftTextSize(16);
        regView.setLeftTextColor(Color.BLACK);
        regView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        regView.setOnClickListener(view -> {

        });
        mainLinear.addView(regView);

        View line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        panModeView = new OptionItemView(mContext);
        panModeView.setPadding(20, 20, 20, 20);
        panModeView.setLayoutParams(linearParams);

        panModeView.setBackground(getSelector());
        panModeView.setLeftImageMarginLeft(20);
        panModeView.setLeftImageMarginRight(18);
        panModeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        panModeView.setLeftText("铁盘模式");
        panModeView.setLeftTextSize(16);
        panModeView.setLeftTextColor(Color.BLACK);
        panModeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        panModeView.setOnClickListener(view -> {

        });
        mainLinear.addView(panModeView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        numberModeView = new OptionItemView(mContext);
        numberModeView.setPadding(20, 20, 20, 20);
        numberModeView.setLayoutParams(linearParams);

        numberModeView.setBackground(getSelector());
        numberModeView.setLeftImageMarginLeft(20);
        numberModeView.setLeftImageMarginRight(18);
        numberModeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        numberModeView.setLeftText("检测数量模式");
        numberModeView.setLeftTextSize(16);
        numberModeView.setLeftTextColor(Color.BLACK);
        numberModeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        numberModeView.setOnClickListener(view -> {

        });
        mainLinear.addView(numberModeView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        OptionItemView internalLineView2 = new OptionItemView(mContext);
        internalLineView2.setPadding(20, 20, 20, 20);
        internalLineView2.setLayoutParams(linearParams);

        internalLineView2.setBackground(getSelector());
        internalLineView2.setLeftImageMarginLeft(20);
        internalLineView2.setLeftImageMarginRight(18);
        internalLineView2.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        internalLineView2.setLeftText("开启遮挡优化");
        internalLineView2.setLeftTextSize(16);
        internalLineView2.setLeftTextColor(Color.BLACK);
        internalLineView2.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        internalLineView2.setOnClickListener(view -> {

        });
        mainLinear.addView(internalLineView2);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        amountModeView = new OptionItemView(mContext);
        amountModeView.setPadding(20, 20, 20, 20);
        amountModeView.setLayoutParams(linearParams);

        amountModeView.setBackground(getSelector());
        amountModeView.setLeftImageMarginLeft(20);
        amountModeView.setLeftImageMarginRight(18);
        amountModeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        amountModeView.setLeftText("识别大小份");
        amountModeView.setLeftTextSize(16);
        amountModeView.setLeftTextColor(Color.BLACK);
        amountModeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        amountModeView.setOnClickListener(view -> {

        });
        mainLinear.addView(amountModeView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        autoSplitModeView = new OptionItemView(mContext);
        autoSplitModeView.setPadding(20, 20, 20, 20);
        autoSplitModeView.setLayoutParams(linearParams);
        autoSplitModeView.setBackground(getSelector());
        autoSplitModeView.setLeftImageMarginLeft(20);
        autoSplitModeView.setLeftImageMarginRight(18);
        autoSplitModeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        autoSplitModeView.setLeftText("底片自动划分");
        autoSplitModeView.setLeftTextSize(16);
        autoSplitModeView.setLeftTextColor(Color.BLACK);
        autoSplitModeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        autoSplitModeView.setOnClickListener(view -> {

        });
        mainLinear.addView(autoSplitModeView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        saveDaysView = new OptionItemView(mContext);
        saveDaysView.setPadding(20, 20, 20, 20);
        saveDaysView.setLayoutParams(linearParams);

        saveDaysView.setBackground(getSelector());
        saveDaysView.setLeftImageMarginLeft(20);
        saveDaysView.setLeftImageMarginRight(18);
        saveDaysView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        saveDaysView.setLeftText("保存周期/天");
        saveDaysView.setLeftTextSize(16);
        saveDaysView.setLeftTextColor(Color.BLACK);
        saveDaysView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        saveDaysView.setOnClickListener(view -> {

        });
        mainLinear.addView(saveDaysView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        matchNumberView = new OptionItemView(mContext);
        matchNumberView.setPadding(20, 20, 20, 20);
        matchNumberView.setLayoutParams(linearParams);

        matchNumberView.setBackground(getSelector());
        matchNumberView.setLeftImageMarginLeft(20);
        matchNumberView.setLeftImageMarginRight(18);
        matchNumberView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        matchNumberView.setLeftText("返回识别个数");
        matchNumberView.setLeftTextSize(16);
        matchNumberView.setLeftTextColor(Color.BLACK);
        matchNumberView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        matchNumberView.setOnClickListener(view -> {

        });
        mainLinear.addView(matchNumberView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        templateNumberView = new OptionItemView(mContext);
        templateNumberView.setPadding(20, 20, 20, 20);
        templateNumberView.setLayoutParams(linearParams);
        templateNumberView.setBackground(getSelector());
        templateNumberView.setLeftImageMarginLeft(20);
        templateNumberView.setLeftImageMarginRight(18);
        templateNumberView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        templateNumberView.setLeftText("菜品最大底片数");
        templateNumberView.setLeftTextSize(16);
        templateNumberView.setLeftTextColor(Color.BLACK);
        templateNumberView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        templateNumberView.setOnClickListener(view -> {

        });
        mainLinear.addView(templateNumberView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        templateThresholdView = new OptionItemView(mContext);
        templateThresholdView.setPadding(20, 20, 20, 20);
        templateThresholdView.setLayoutParams(linearParams);

        templateThresholdView.setBackground(getSelector());
        templateThresholdView.setLeftImageMarginLeft(20);
        templateThresholdView.setLeftImageMarginRight(18);
        templateThresholdView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        templateThresholdView.setLeftText("未录入阈值");
        templateThresholdView.setLeftTextSize(16);
        templateThresholdView.setLeftTextColor(Color.BLACK);
        templateThresholdView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        templateThresholdView.setOnClickListener(view -> {

        });
        mainLinear.addView(templateThresholdView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        borderShowView = new OptionItemView(mContext);
        borderShowView.setPadding(20, 20, 20, 20);
        borderShowView.setLayoutParams(linearParams);

        borderShowView.setBackground(getSelector());
        borderShowView.setLeftImageMarginLeft(20);
        borderShowView.setLeftImageMarginRight(18);
        borderShowView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        borderShowView.setLeftText("显示边框");
        borderShowView.setLeftTextSize(16);
        borderShowView.setLeftTextColor(Color.BLACK);
        borderShowView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        borderShowView.setOnClickListener(view -> {

        });
        mainLinear.addView(borderShowView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        nameShowView = new OptionItemView(mContext);
        nameShowView.setPadding(20, 20, 20, 20);
        nameShowView.setLayoutParams(linearParams);
        nameShowView.setBackground(getSelector());
        nameShowView.setLeftImageMarginLeft(20);
        nameShowView.setLeftImageMarginRight(18);
        nameShowView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        nameShowView.setLeftText("显示菜品名称");
        nameShowView.setLeftTextSize(16);
        nameShowView.setLeftTextColor(Color.BLACK);
        nameShowView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        nameShowView.setOnClickListener(view -> {

        });
        mainLinear.addView(nameShowView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        priceShowView = new OptionItemView(mContext);
        priceShowView.setPadding(20, 20, 20, 20);
        priceShowView.setLayoutParams(linearParams);

        priceShowView.setBackground(getSelector());
        priceShowView.setLeftImageMarginLeft(20);
        priceShowView.setLeftImageMarginRight(18);
        priceShowView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        priceShowView.setLeftText("显示菜品价格");
        priceShowView.setLeftTextSize(16);
        priceShowView.setLeftTextColor(Color.BLACK);
        priceShowView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        priceShowView.setOnClickListener(view -> {

        });
        mainLinear.addView(priceShowView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        borderSizeView = new OptionItemView(mContext);
        borderSizeView.setPadding(20, 20, 20, 20);
        borderSizeView.setLayoutParams(linearParams);

        borderSizeView.setBackground(getSelector());
        borderSizeView.setLeftImageMarginLeft(20);
        borderSizeView.setLeftImageMarginRight(18);
        borderSizeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        borderSizeView.setLeftText("边框粗细");
        borderSizeView.setLeftTextSize(16);
        borderSizeView.setLeftTextColor(Color.BLACK);
        borderSizeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        borderSizeView.setOnClickListener(view -> {

        });
        mainLinear.addView(borderSizeView);


        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        fontSizeView = new OptionItemView(mContext);
        fontSizeView.setPadding(20, 20, 20, 20);
        fontSizeView.setLayoutParams(linearParams);

        fontSizeView.setBackground(getSelector());
        fontSizeView.setLeftImageMarginLeft(20);
        fontSizeView.setLeftImageMarginRight(18);
        fontSizeView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        fontSizeView.setLeftText("字体大小");
        fontSizeView.setLeftTextSize(16);
        fontSizeView.setLeftTextColor(Color.BLACK);
        fontSizeView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        fontSizeView.setOnClickListener(view -> {

        });
        mainLinear.addView(fontSizeView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        borderColorView = new OptionItemView(mContext);
        borderColorView.setPadding(20, 20, 20, 20);
        borderColorView.setLayoutParams(linearParams);
        borderColorView.setBackground(getSelector());
        borderColorView.setLeftImageMarginLeft(20);
        borderColorView.setLeftImageMarginRight(18);
        borderColorView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        borderColorView.setLeftText("边框颜色");
        borderColorView.setLeftTextSize(16);
        borderColorView.setLeftTextColor(Color.BLACK);
        borderColorView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        borderColorView.setOnClickListener(view -> {

        });
        mainLinear.addView(borderColorView);

        line = new View(mContext);
        line.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
        line.setBackgroundColor(Color.rgb(224, 224, 224));
        mainLinear.addView(line);

        fontColorView = new OptionItemView(mContext);
        fontColorView.setPadding(20, 20, 20, 20);
        fontColorView.setLayoutParams(linearParams);

        fontColorView.setBackground(getSelector());
        fontColorView.setLeftImageMarginLeft(20);
        fontColorView.setLeftImageMarginRight(18);
        fontColorView.setLeftImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.setting_icon))));
        fontColorView.setLeftText("字体颜色");
        fontColorView.setLeftTextSize(16);
        fontColorView.setLeftTextColor(Color.BLACK);
        fontColorView.setRightImage(drawableToBitmap(Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.mipmap.enter_icon))));
        fontColorView.setOnClickListener(view -> {

        });
        mainLinear.addView(fontColorView);
        return scrollView;
    }

}
